#!/bin/bash
trap 'echo Abort ; exit 1' ERR
err() { echo "Error. $@ not set."; exit 1; }
. .varlist
[ -z "$SOURCE_DIR" ] && err SOURCE_DIR
[ -z "$LINUX" ] && err LINUX
[ -z "$TOOLCHAIN_DIR" ] && err TOOLCHAIN_DIR

echo Install kernel header.

[ -f $TOOLCHAIN_DIR/.$LINUX ] && exit 0
cd $SOURCE_DIR/$LINUX
set -x
make mrproper >/dev/null
make ARCH=arm headers_check >/dev/null
make ARCH=arm INSTALL_HDR_PATH=$TOOLCHAIN_DIR/usr at91sam9263ek_defconfig >/dev/null
make ARCH=arm INSTALL_HDR_PATH=$TOOLCHAIN_DIR/usr headers_install >/dev/null

touch $TOOLCHAIN_DIR/.$LINUX
